package Controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;

import Entity.Customer;
import DB.CustomerQuery;
import Communication.Client;
import View.UpdateCustomerDeatilsView;
import View.UpdateCustomerView;
import Communication.Client;
import Communication.MessageHandle;

/** This class controls and manages the process that allows salesman to update customer history card */
public class UpdateCustomerDetailsController implements Serializable{
	private static final long serialVersionUID = 42L;
	/**  Required attributes */
		CustomerQuery customerQuery;
		UpdateCustomerDeatilsView customerDetailView;
		Client client;

		
		/**
		 * Constructor calling to listener class that attached to the process
		 * @param client
		 * @param updateCustomerController
		 */
		public UpdateCustomerDetailsController(Client client, UpdateCustomerController updateCustomerController) {
			this.client = client;
			customerDetailView =  new UpdateCustomerDeatilsView();
			customerQuery= new CustomerQuery();
			//customerDetailView.addUpdateCustomerDetailsListener(new UpdateCustomerDetailsInfoListener(updateCustomerController));
		}
		
		/**  Inner Listener class */ 		
		class UpdateCustomerDetailsInfoListener implements ActionListener
		{
			UpdateCustomerController updateDetailController;
			public UpdateCustomerDetailsInfoListener(UpdateCustomerController updateDetailController){
				this.updateDetailController = updateDetailController;
				//customerQuery= new CustomerQuery();
				customerDetailView.showWindow();
			}


			/**
			 * Handle Actions
			 */
			public void actionPerformed(ActionEvent event) {
				System.out.print("yes");
				if (event.getSource() == customerDetailView.getBackBtn())
				{  
					updateDetailController.showWindow();
					customerDetailView.hideWindow();
				}
				else if (event.getSource() == customerDetailView.getUpdateBtn()){
					}
			}
		}
}
